from selenium.webdriver.common.by import By

from Base.base_page import AppBasePage


class LoginAppPage(AppBasePage):
    def __init__(self):
        super().__init__()
        # self.agree_button = (By.XPATH, '//*[@text="同意"]')
        self.no_button = (By.XPATH, '//*[@text="未登录"]')
        self.other_login = (By.XPATH,'//*[@text="其他登录方式"]')
        self.pwd_login = (By.XPATH,'//*[@text="密码登录"]')
        self.xy = (By.XPATH,'//*[@content-desc="已阅读并同意 用户协议 和 账号信息处理规则 "]')
        self.phone = (By.XPATH,'//*[@text="手机号/邮箱"]')
        self.password = (By.XPATH,'//*[@text="密码"]')
        self.login_button = (By.XPATH,'//*[@text="登录"]')
        self.nologin_button = (By.XPATH,'(//*[@resource-id="com.ss.android.article.news:id/hzj"])[4]')
        # self.close_button = (By.XPATH,'//*[@content-desc="关闭"]')

    def app_login(self,pho,pwd):
        self.click_element(self.find_element(self.no_button))
        self.click_element(self.find_element(self.other_login))
        self.click_element(self.find_element(self.pwd_login))
        self.click_element(self.find_element(self.xy))
        self.input_text(self.find_element(self.phone),pho)
        self.input_text(self.find_element(self.password),pwd)
        self.click_element(self.find_element(self.login_button))
        self.click_element(self.find_element(self.nologin_button))
        # self.click_element(self.find_element(self.close_button))